#ifndef     __SENSOR_H
#define     __SENSOR_H

#include "../../utils/object.h"
#include "../../utils/nocopyable.h"
#include "../../rtos/mutex.h"
#include "../../utils/base.h"

namespace driver {

class Sensor : private utils::NoCopyable {

public:
    Sensor();

    inline bool is_max_door_close() {
        return utils::is_set_bit<0>(read());
    }

    inline bool is_min_door_close() {
        return utils::is_set_bit<1>(read());
    }

    inline bool is_lock_close() {
        return utils::is_set_bit<2>(read());
    }
    
    inline bool is_cup1_sensor() {
        return utils::is_clr_bit<6>(read());
    }

    inline bool is_cup2_sensor() {
        return utils::is_clr_bit<7>(read());
    }

    inline bool is_step_origin() {
        return utils::is_set_bit<8>(read());
    }

    inline bool is_drop_ice() {
        return utils::is_set_bit<10>(read());
    }

    inline bool is_drop_pearl() {
        return utils::is_set_bit<11>(read());
    }

    inline bool is_drop_milk() {
        return utils::is_set_bit<12>(read());
    }

    inline bool is_drop_arm() {
        return utils::is_set_bit<13>(read());
    }

    inline bool is_drop_cup1() {
        return utils::is_set_bit<14>(read());
    }

    inline bool is_drop_cup2() {
        return utils::is_set_bit<15>(read());
    }

    uint16_t status();

private:
    uint16_t read();

    rtos::Mutex m_mutex;
};

inline utils::Object<Sensor> sensor;

}

#endif
